<template>
    <h3 style="text-align: center;" >
        登录页面
    </h3>
    <table class="table table-bordered" border="1">
        <tr>
            <td>
                用户名
            </td>
            <td>
                <input type="text" v-model="Info.T_Name" placeholder="请输入用户名">
            </td>
        </tr>
        <tr>
            <td>
                密码
            </td>
            <td>
                <input type="password" v-model="Info.T_Pwd" placeholder="请输入密码">
            </td>
        </tr>
        <tr style="text-align: center;">
            <td colspan="2">
                <button class="btn btn-primary" @click="Adduser">登录</button>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router';
const router = useRouter();
import { ref } from 'vue';
//双向绑定注册
const Info=ref({
    T_Id:'',
    T_Name:'',
    T_Pwd:'',
    T_Date:'',
})
import axios from 'axios';
//登录
const Adduser=()=>{
    axios.get('https://localhost:44369/api/Userl/LoginUser',
    {
       params:{
           T_Name:Info.value.T_Name,
           T_Pwd:Info.value.T_Pwd
       }
    }).then((res)=>{
       if(res.data==1)
       {
           alert("登录成功");
           router.push('/ShowLogin');    
       }
       else if(res.data==11){
           alert("用户不存在");
       }
       else if(res.data==22)
       {
           alert("密码错误");
       }
       else{
           alert("登录失败");
       }
        console.log(res);
    })
}
</script>